package com.zlzlib.libdialog;


import android.content.Context;
import android.graphics.Color;
import android.view.Gravity;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;

/**
 * Created by zlz on 2018/8/8.
 */
public class UpdateTipDialog extends TipDialog {

    private TextView tv_version;
    private ImageView img_icon;

    public UpdateTipDialog(Context context) {
        super(context);
    }

    protected void initView() {
        super.initView();
        setCancelable(false);
        setCanceledOnTouchOutside(false);
        //添加 版本和 图片位置
        tv_version = new TextView(context);
        LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(
                ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
        lp.topMargin = (int) context.getResources().getDimension(R.dimen.dp_8);
        mBinding.content.addView(tv_version, 1, lp);
        tv_version.setTextColor(Color.RED);
        tv_version.setTextSize(20);
        int iconW = (int) context.getResources().getDimension(R.dimen.dp_45);
        img_icon = new ImageView(context);
        LinearLayout.LayoutParams lpIcon = new LinearLayout.LayoutParams(iconW, iconW);
        lpIcon.topMargin = (int) context.getResources().getDimension(R.dimen.dp_10);
        lpIcon.bottomMargin = (int) context.getResources().getDimension(R.dimen.dp_10);
        mBinding.content.addView(img_icon, 2, lpIcon);
        mBinding.tvMsg.setGravity(Gravity.LEFT);
    }

    public UpdateTipDialog setUpdateVersion(String s) {
        tv_version.setText(s);
        return this;
    }


    public UpdateTipDialog setAppIcon(int icon) {
        img_icon.setImageResource(icon);
        return this;
    }

}
